﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%option explicit
Response.Buffer = True    
Response.ExpiresAbsolute = Now() - 1    
Response.Expires = 0    
Response.CacheControl = "no-cache"
%>
<%
Dim RZ_IN
RZ_IN=1
%>
<!--#include file="../conn.inc.asp" -->
<!--#include file="../client_inc/common.function.asp" -->
<!--#include file="../client_inc/common.class.asp" -->
<!--#Include file="../client_inc/sqlsecure.asp"-->
<%
Dim proc,id,cookiehits
proc=HTMLEncode(request.QueryString("proc"))
id=HTMLEncode(request.QueryString("id"))
If Not isNumber(id) Or (proc<>"ars" And proc<>"phs" And proc<>"prs" And proc<>"jbs") Then 
	response.write("")
	response.End()
Else
	cookiehits=request.cookies(proc&id)
	Dim refreshtime
	refreshtime=app("rz_refreshtime")
	If Not IsEmpty(Session("visit2")) and isNumber(Session("visit2")) and int(refreshtime) > 0 Then
		if (timer()-int(Session("visit2")))*1000 < refreshtime * 1000 then
		   response.write(cookiehits)
		   Session("visit2") = timer()
		   Response.end
		end if
	End If
	Session("visit2") = timer()
	If cookiehits<>"" Then 
		Call addhits(proc,id,0)
	Else 
		Call addhits(proc,id,1)
	End If 
End If 

function addhits(proc,id,isadd)
	dim dbname,rs,sql
	select case proc
		case "ars":
			dbname="c_article"
		case "phs"
			dbname="c_photo"
		case "prs"
			dbname="c_product"
		case "jbs"
			dbname="c_job"
	end  Select
	Dim rhits
	sql = "select hits from ["&dbname&"] where  id="&id
	Set rs = Server.CreateObject("ADODB.Recordset")
	If isadd=1 Then 
		rs.open sql,conn,1,3
		If Not rs.eof Then 
			rs("hits")=rs("hits")+1
			rs.update
			rhits=rs("hits")
		End If 
	Else
		rs.open sql,conn,1,1
		If Not rs.eof Then 
			rhits=rs("hits")
		End If
	End If 
	rs.close
	Set rs=Nothing
	response.cookies(proc&id)=rhits
	response.write(rhits)
end Function
%>	
